package com.java.base.exercise.util;

import com.java.base.exercise.People;
import org.springframework.cglib.reflect.FastClass;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * @Author RenPu
 * @Date 2021/8/9 14:45
 * @Version 1.0
 * @Description:
 **/
public class Title {
    public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException, InvocationTargetException {
        A myThread = new A();

        Thread thread = new Thread(myThread);
//        thread.setDaemon(true); //设置为守护线程
        thread.run();

        try {
            thread.join();

            System.out.println("业务线程--------" + thread.getName() + "线程执行完毕------------------");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName() + "线程执行完毕------------------");

        //cglib反射调用
        FastClass fastClass = FastClass.create(People.class);
        People o1 = (People) fastClass.newInstance();
        System.out.println(o1.test2("cglib+454654654"));


        //JDK反射调用
        Class<?> aClass = Class.forName("com.java.base.exercise.People");
        People o = (People) aClass.newInstance();
        System.out.println(o.test2("ffafafafa"));


    }
}

class A implements Runnable {

    @Override
    public void run() {
        System.out.println("-----------------65465465465");
    }
}